var initialdet=new Object();
var xmld,thisObject;
var InitialAssetsProxy = Objs("model.InitialAssetsProxy",
	Proxy,
{
	initialize: function( name,lists)
	{ 
		InitialAssetsProxy.$super.initialize.call( this, name,lists);
		thisObject=this;
        this.loadAssets();
	},	
	
	 loadAssets:function()
 {
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=initialAssets",
				
				success: function(data) {	
				var assetsdata= eval('(' + data + ')');
				initialdet.drivetrain = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.drivetrian.length;i++)
				{
				initialdet.drivetrain += '<option value='+assetsdata.drivetrian[i].asset_id+'>'+assetsdata.drivetrian[i].asset_name+'</option>';
				}
				initialdet.enginexml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.engine.length;i++)
				{
				initialdet.enginexml += '<option value='+assetsdata.engine[i].asset_id+'>'+assetsdata.engine[i].asset_name+'</option>';
				}
				initialdet.transxml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.transmission.length;i++)
				{
				initialdet.transxml += '<option value='+assetsdata.transmission[i].asset_id+'>'+assetsdata.transmission[i].asset_name+'</option>';
				}
				initialdet.want = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.want.length;i++)
				{
				initialdet.want += '<option value='+assetsdata.want[i].asset_id+'>'+assetsdata.want[i].asset_name+'</option>';
				}
				initialdet.paperxml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.paperwork.length;i++)
				{
				initialdet.paperxml += '<option value='+assetsdata.paperwork[i].asset_id+'>'+assetsdata.paperwork[i].asset_name+'</option>';
				}
				initialdet.adsourcexml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.adsource.length;i++)
				{
				initialdet.adsourcexml += '<option value='+assetsdata.adsource[i].asset_id+'>'+assetsdata.adsource[i].asset_name+'</option>';
				}
			initialdet.contactxml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.contact.length;i++)
				{
				initialdet.contactxml += '<option value='+assetsdata.contact[i].asset_id+'>'+assetsdata.contact[i].asset_name+'</option>';
				}
			initialdet.optionDelivery = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.deliver.length;i++)
				{
				initialdet.optionDelivery += '<option value='+assetsdata.deliver[i].asset_id+'>'+assetsdata.deliver[i].asset_name+'</option>';
				}
			initialdet.located = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.located.length;i++)
				{
				initialdet.located += '<option value='+assetsdata.located[i].asset_id+'>'+assetsdata.located[i].asset_name+'</option>';
				}
			initialdet.transportationxml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.transportation.source.length;i++)
				{
				initialdet.transportationxml += '<option>'+assetsdata.transportation.source[i].company_name+'</option>';
				}
                 initialdet.statexml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.states.length;i++)
				{
				initialdet.statexml += '<option value="'+assetsdata.states[i].state_code+'">'+assetsdata.states[i].state+'</option>';
				}
                                
                initialdet.makexml = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.makes.length;i++)
				{
				initialdet.makexml += '<option value='+assetsdata.makes[i].make_id +'>'+ assetsdata.makes[i].make+'</option>';
				}
				initialdet.searchCtra = "<option value='0'>--Choose One--</option>";
				for(i=0;i<assetsdata.search.length;i++)
				{
				initialdet.searchCtra += '<option value='+ assetsdata.search[i].asset_datafield +'>'+ assetsdata.search[i].asset_name+'</option>';
				}
				for(i=0;i<assetsdata.tow_status.length;i++)
				{
				initialdet.towstatus = '<option>'+assetsdata.tow_status[i].a_name+'</option>';
				}
				
         
				thisObject.sendNotification( NotificationNames.LOAD_SUCCESS_2, 'li' );	
			
		}
		});
		},
		setmodel:function()
		{
		var makeval=new Object();
	
	//$('select#v_model').empty();
		makeval.make_id=$("#make").val();
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getModelByMake",
				data:makeval,
				success: function(data) {
				var data= eval('(' + data + ')');
				initialdet.modelxml = "<option value='0'>--Choose One--</option>";
				  for(i=0;i<data.models.models.length;i++)
				{
				initialdet.modelxml += '<option value='+data.models.models[i].model_id +'>'+ data.models.models[i].model_name+'</option>';
				
				
				
				}
				$('select#model').empty();
				$("#model").append(initialdet.modelxml);
				$("#model").trigger("change");

				if(vehicleSingle.model)
				document.getElementById('model').value = vehicleSingle.model;
				else
				document.getElementById('model').value =0;
				//document.getElementById('v_model').value = vehicleSingle.model;
				}
				});
		},
		setvmodel:function()
		{
		var makeval=new Object();
	
	//$('select#v_model').empty();
		makeval.make_id=$("#v_make").val();
		$.ajax({
				type: "POST",
				url:"../services/AssetService.php?action=getModelByMake",
				data:makeval,
				success: function(data) {
				var data= eval('(' + data + ')');
				initialdet.modelxml = "<option value='0'>--Choose One--</option>";
				  for(i=0;i<data.models.models.length;i++)
				{
				initialdet.modelxml = '<option value='+data.models.models[i].model_id +'>'+ data.models.models[i].model_name+'</option>';
			
				
				}
				$('select#v_model').empty();
					
				$("#v_model").append(initialdet.modelxml);
				$("#v_model").trigger("change");
			
		
				document.getElementById('v_model').value = vehicleSingle.model;
				//document.getElementById('v_model').value = vehicleSingle.model;
				}
				});
		}
});
 